{extend name="../../admin/view/common/main"/}
{block name="style"}
<link href="__STATIC__/common/lib/zui/lib/datetimepicker/datetimepicker.css" rel="stylesheet" type="text/css">
<link href="__STATIC__/common/lib/zui/lib/board/zui.board.min.css" rel="stylesheet">
<link href="__STATIC__/common/lib/zui/lib/chosen/chosen.min.css" rel="stylesheet">
<link href="__STATIC__/common/lib/zui/lib/chosenicons/zui.chosenicons.min.css" rel="stylesheet">
<link href="__STATIC__/common/lib/webuploader/css/webuploader.css" rel="stylesheet" type="text/css">
{/block}
{block name="body"}
<div class="builder">
    <div class="main-title">
        <h2>{$title} {if condition="$suggest"}<small>（{$suggest}）</small>{/if}</h2>
    </div>
    <div class="with-padding">

        <div class="tab-wrap">
            <ul class="nav nav-pills group_nav">
                {volist name="group" id="vGroup"}
                    <li class="{if condition='$i eq 1'}active{/if}"><a href="javascript:">{$key}</a></li>
                {/volist}
            </ul>
        </div>

        <form action="{$savePostUrl}" method="post" class="form-horizontal ajax-form">
        {php}if($group){{/php}
            {volist name="group" id="vGroup"}
                <div class="group_list" style="{if condition='$i neq 1'}display: none;{/if}">
                    {volist name="keyList" id="field"}
                        {php}if(in_array($field['name'],$vGroup)){{/php}
                        {include file="../../admin/view/builder/_key"/}
                        {php}}{/php}
                    {/volist}
                </div>
            {/volist}

        {php}}else{{/php}
            {volist name="keyList" id="field"}
            {include file="../../admin/view/builder/_key"/}
            {/volist}
        {php}}{/php}
        <br/>

            <div class="form-item">
                {volist name="buttonList" id="button"}
                    <button {$button.attr}>{$button.title}</button>  &nbsp;
                {/volist}
            </div>
        </form>
    </div>
</div>
{/block}

{block name="script"}

<script>
    $(function () {
        $('.form-datetime').datetimepicker({
            language: "zh-CN",
            autoclose: true,
            format: 'yyyy-mm-dd hh:ii'
        });
        $('.form-date').datetimepicker({
            language: "zh-CN",
            minView: 2,
            autoclose: true,
            format: 'yyyy-mm-dd'
        });
        $('.form-time').datetimepicker({
            language: "zh-CN",
            minView: 0,
            startView:1,
            autoclose: true,
            format: 'hh:ii'
        });
        $('.time').change(function () {
            var fieldName = $(this).attr('data-field-name');
            var dateString = $(this).val();
            var date = new Date(dateString);
            var timestamp = date.getTime();
            $('[name=' + fieldName + ']').val(Math.floor(timestamp / 1000));
        });
    });

    $(function () {
        //多选框数据处理
        function implode(x, list) {
            var result = "";
            for (var i = 0; i < list.length; i++) {
                if (result == "") {
                    result += list[i];
                } else {
                    result += ',' + list[i];
                }
            }
            return result;
        }

        $('.oneplus-checkbox').change(function (e) {
            var fieldName = $(this).attr('data-field-name');
            var checked = $('.oneplus-checkbox[data-field-name=' + fieldName + ']:checked');
            var result = [];
            for (var i = 0; i < checked.length; i++) {
                var checkbox = $(checked.get(i));
                result.push(checkbox.attr('value'));
            }
            result = implode(',', result);
            $('.oneplus-checkbox-hidden[data-field-name=' + fieldName + ']').val(result);
        });
    });
</script>

<script type="text/javascript">
    $(function () {
        $('.group_nav li a').click(function () {
            $('.group_list').hide();
            $('.group_list').eq($(".group_nav li a").index(this)).show();
            $('.group_nav li').removeClass('active');
            $(this).parent().addClass('active');
        })
    })
    Think.setValue("type", {$info.type|default=0});
    Think.setValue("group", {$info.group|default=0});
</script>

<script type="text/javascript" src="__STATIC__/common/lib/zui/lib/datetimepicker/datetimepicker.min.js"></script>
<script type="text/javascript" charset="utf-8" src="__STATIC__/common/lib/webuploader/js/webuploader.js"></script>
<!--chosenICON 依赖资源引入-->
<script type="text/javascript" src="__STATIC__/common/lib/zui/lib/chosenicons/zui.chosenicons.min.js"></script>
<!--chosen 依赖资源引入-->
<script type="text/javascript" src="__STATIC__/common/lib/zui/lib/chosen/chosen.min.js"></script>
<!--新版看板资源引入-->
<script type="text/javascript" src="__STATIC__/common/lib/zui/lib/board/zui.board.min.js"></script>
{notempty name="myJs"}
    {$myJs}
{/notempty}

{/block}
